// import { login, logout } from '@/api/login'
import { loginApi, updateMemberApi } from '../api/common'
import { setUserInfo, removeUserInfo } from '../utils/auth'

const user = {
  state: {
    userInfo: {}
  },

  mutations: {
    SET_USERINFO: (state, userInfo) => {
      state.userInfo = userInfo
    }
  },

  actions: {
    async SetUserInfoAct ({ commit }, params) {
      const userInfo = await loginApi(params)
      commit('SET_USERINFO', userInfo)
      setUserInfo(userInfo)
    },
    async UpdateUserInfoAct ({ commit }, params) {
      const userInfo = await updateMemberApi(params)
      commit('SET_USERINFO', userInfo)
      setUserInfo(userInfo)
    }
  }
}

export default user
